package com.sgb.kjwl.view.ui.fragment.home;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.apeng.permissions.EsayPermissions;
import com.apeng.permissions.OnPermission;
import com.chuanglan.shanyan_sdk.OneKeyLoginManager;
import com.chuanglan.shanyan_sdk.listener.OneKeyLoginListener;
import com.chuanglan.shanyan_sdk.listener.OpenLoginAuthListener;
import com.sgb.alimaplibrary.util.ToastUtil;
import com.sgb.jicai.view.adapter.HomeHostVideoAdapter;
import com.sgb.kjwl.AppLazyFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.api.GsonManager;
import com.sgb.kjwl.databinding.FragmentRecommendBinding;
import com.sgb.kjwl.di.home.DaggerHomeFragComponent;
import com.sgb.kjwl.di.home.HomeFragModule;
import com.sgb.kjwl.model.entity.BiddingEntity;
import com.sgb.kjwl.model.entity.LoginEntity;
import com.sgb.kjwl.model.entity.UserMsgEntity;
import com.sgb.kjwl.model.entity.pick.PickInfoListEntity;
import com.sgb.kjwl.model.entity.pick.PreNoticeItemEntity;
import com.sgb.kjwl.model.entity.pick.TenderAllListEntity;
import com.sgb.kjwl.model.entity.pick.TenderAllListNewEntity;
import com.sgb.kjwl.view.ui.adapter.pick.PickHallAllNewAdapter;
import com.swgk.core.base.model.entity.VideoBean;
import com.sgb.kjwl.model.entity.user.OneKeyLoginEntity;
import com.sgb.kjwl.model.entity.user.PickCompanyListEntity;
import com.sgb.kjwl.utils.ConfigUtils;
import com.sgb.kjwl.view.event.LoginEvent;
import com.sgb.kjwl.view.event.self.MachinePublishEvent;
import com.sgb.kjwl.view.ui.activity.MainActivity;
import com.sgb.kjwl.view.ui.activity.WebViewX5HostActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.activity.pick.PickNoticeBidDetailActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.sgb.kjwl.view.ui.adapter.pick.PickBidingAdapter;
import com.sgb.kjwl.view.ui.adapter.pick.PickCompanyListAdapter;
import com.sgb.kjwl.view.ui.adapter.pick.PickHallAllAdapter;
import com.sgb.kjwl.view.ui.adapter.pick.PickInfoListAdapter;
import com.sgb.kjwl.view.ui.adapter.pick.PickWinningNoticeAdapter;
import com.sgb.kjwl.viewmodel.home.PickListFragModel;
import com.sgb.knowledgeshare.utils.SharePermissionUtils;
import com.sgb.knowledgeshare.view.activity.HomeShareActivity;
import com.sgb.knowledgeshare.view.activity.PlayListActivity;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.base.model.entity.VideoBean;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.event.EventConstant;
import com.swgk.core.mmkvutil.CacheMarker;
import com.swgk.core.mmkvutil.MkvUtils;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.refresh.SuperSwipeRefreshLayout;
import com.swgk.core.util.MLog;
import com.swgk.core.util.SharedPreferenceUtil;
import com.swgk.core.xrecyclerview.XRecyclerView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.io.Serializable;
import java.util.List;
import java.util.concurrent.TimeUnit;

import javax.inject.Inject;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * Description:
 * Author CFK
 */
public class PickListFragment extends AppLazyFragment {
    public static final String TAG = "";
    public static final String KEY_TYPE = "type";
    private MainActivity activity;

    private FragmentRecommendBinding binding;
    private String type = "";
    private SuperSwipeRefreshLayout swipeRefreshMainRecruitmentFragment;
    private boolean isLoadMore = false;
    private int page = 1;
    @Inject
    PickListFragModel viewModel;

    private PickHallAllNewAdapter pickBidingAdapter;
    private PickCompanyListAdapter pickCompanyListAdapter;
    private PickInfoListAdapter pickInfoListAdapter;
    private PickWinningNoticeAdapter pickWinningNoticeAdapter;
    private PickHallAllAdapter pickHallAllAdapter;
    private String typeNoPosition = "0";
    private String goodsTypeNoPosition = "";
    private String typeNoOnePosition = "全部";
    private HomeHostVideoAdapter homeHostVideoAdapter;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (context instanceof MainActivity) {
            activity = (MainActivity) context;
        }
    }

    @Override
    protected void setupFragmentComponent(AppComponent appComponent) {
        DaggerHomeFragComponent.builder()
                .appComponent(appComponent)
                .homeFragModule(new HomeFragModule(this))
                .build()
                .inject(this);
    }

    public static PickListFragment newInstance(String type) {
        PickListFragment fragment = new PickListFragment();
        Bundle bundle = new Bundle();
        bundle.putString(KEY_TYPE, type);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_recommend, container, false);
        binding.setViewModel(viewModel);
        return binding.getRoot();
    }

    /**
     * 下拉刷新界面
     *
     * @param swipeRefreshMainRecruitmentFragment
     */
    public void onPullRefresh(SuperSwipeRefreshLayout swipeRefreshMainRecruitmentFragment) {
        this.swipeRefreshMainRecruitmentFragment = swipeRefreshMainRecruitmentFragment;
        swipeRefreshMainRecruitmentFragment.setLoadMore(false);
        page = 1;
        this.isLoadMore = false;
        MLog.e("招采大厅", "刷新 当前所在界面 type=" + type + "page == " + page);
        updateData();
    }

    public void updateView() {
        if (swipeRefreshMainRecruitmentFragment != null) {
            swipeRefreshMainRecruitmentFragment.setRefreshing(true);
            swipeRefreshMainRecruitmentFragment.setLoadMore(false);
        }
        binding.rlvOption.loadMoreComplete();
    }

    @Override
    protected void initView() {
        page = 1;
        isLoadMore = false;
        if (type != null) {
            DividerItemDecoration divider = new DividerItemDecoration(activity, DividerItemDecoration.VERTICAL);
            divider.setDrawable(ContextCompat.getDrawable(activity, R.drawable.shape_list_divide2));
            binding.rlvOption.addItemDecoration(divider);
            binding.rlvOption.setPullRefreshEnabled(false);
            binding.rlvOption.setLoadingMoreEnabled(true);
            binding.rlvOption.setLoadingListener(new XRecyclerView.LoadingListener() {
                @Override
                public void onRefresh() {
                }

                @SuppressLint("CheckResult")
                @Override
                public void onLoadMore() {
                    binding.rlvOption.setPullRefreshEnabled(false);
                    Observable.timer(2000, TimeUnit.MILLISECONDS)
                            .subscribeOn(Schedulers.io())
                            .observeOn(AndroidSchedulers.mainThread())
                            .subscribe(aLong -> {
                                binding.rlvOption.loadMoreComplete();
                            });
                    page++;
                    isLoadMore = true;
                    MLog.e("招采大厅", "加载更多 当前所在界面 type=" + type + ",page == " + page);
                    updateData();
                }
            });
        }

        binding.tvMore.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharePermissionUtils.getPermission(getActivity());
            }
        });

       /* binding.imgBackTop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                binding.imgBackTop.setVisibility(View.GONE);
                if (getParentFragment() instanceof MainRecruitmentFragment) {
                    MainRecruitmentFragment mainRecruitmentFragment = (MainRecruitmentFragment) getParentFragment();
                    mainRecruitmentFragment.scrollToTop();
                }
                if ("share".equals(type)) {
                    binding.rlvOptionShare.scrollToPosition(0);
                } else {
                    binding.rlvOption.scrollToPosition(0);
                }
            }
        });*/
    }

    private void updateData() {
        if (pickHallAllAdapter == null) {
            pickHallAllAdapter = new PickHallAllAdapter(getContext(), null);
        }
        switch (type) {
            case "openBid": //竞价采购
                viewModel.getBiddingList(page, typeNoPosition, goodsTypeNoPosition);
                break;
            case "companyInfo": //招采企业
                viewModel.getCompanyData(page);
                break;
            case "pickInfo": //招标信息
                viewModel.getPickInfoList(page, typeNoPosition, goodsTypeNoPosition);
                break;
            case "pickWinningNotice": //中标公告
                viewModel.getBidingData(page, typeNoPosition, goodsTypeNoPosition);
                break;
            case "share":  //知识分享
                binding.neScShare.setVisibility(View.VISIBLE);
                binding.rlvOption.setVisibility(View.GONE);
              //  binding.imgBackTop.setVisibility(View.VISIBLE);
                viewModel.memberVideoShare(page);
                break;
        }
    }

    private void initAdapter() {
        if ("openBid".equals(type)) {//竞价采购
            openBidData();
        } else if ("companyInfo".equals(type)) {//招采企业
            if (pickCompanyListAdapter == null) {
                pickCompanyListAdapter = new PickCompanyListAdapter(activity, null, new PickCompanyListAdapter.CallBack() {
                    @Override
                    public void onItemFocus(PickCompanyListEntity entity, int position) {
                        if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                            jumpLogin();
                        } else {
                            viewModel.userFocus(entity.getCompanyNo(), !entity.getFocus(), position);
                        }
                    }
                });
            }
            LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
            binding.rlvOption.setLayoutManager(layoutManager);
            binding.rlvOption.setAdapter(pickCompanyListAdapter);
            pickCompanyListAdapter.setOnItemClick(new AdapterOnItemClick<PickCompanyListEntity>() {
                @Override
                public void onItemClick(PickCompanyListEntity pickCompanyListEntity, int position) {
                    if (TextUtils.isEmpty(String.valueOf(pickCompanyListEntity.getCompanyNo()))) {
                        ToastUtil.show(activity, "企业店铺no不能为空");
                        return;
                    }
                    WebsiteInfoActivity.start(activity, String.valueOf(pickCompanyListEntity.getCompanyNo()), WebsiteInfoActivity.WEBSITE_FOR_COMPANY);
                }
            });

        } else if ("pickInfo".equals(type)) {//招标信息
            if (pickInfoListAdapter == null) {
                pickInfoListAdapter = new PickInfoListAdapter(activity, null);
            }
            LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
            binding.rlvOption.setLayoutManager(layoutManager);
            binding.rlvOption.setAdapter(pickInfoListAdapter);
            pickInfoListAdapter.setOnItemClick(new AdapterOnItemClick<PickInfoListEntity>() {
                @Override
                public void onItemClick(PickInfoListEntity tenderListEntity, int position) {
                    viewModel.getH5Url(tenderListEntity.getId(), "tenderNoticeDetail");
                }
            });
        } else if ("pickWinningNotice".equals(type)) {//中标公告
            viewModel.getBidingData(page, typeNoPosition, goodsTypeNoPosition);
            if (pickWinningNoticeAdapter == null) {
                pickWinningNoticeAdapter = new PickWinningNoticeAdapter(activity, null);
            }
            LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
            binding.rlvOption.setLayoutManager(layoutManager);
            binding.rlvOption.setAdapter(pickWinningNoticeAdapter);
            pickWinningNoticeAdapter.setOnItemClick(new AdapterOnItemClick<PreNoticeItemEntity>() {
                @Override
                public void onItemClick(PreNoticeItemEntity goodsInfoEntity3, int position) {
                    //中标
                    PickNoticeBidDetailActivity.start(activity, goodsInfoEntity3.getTenderNo() + "");
                }
            });
        } else if ("share".equals(type)) { //知识分享
            if (homeHostVideoAdapter == null) {
                homeHostVideoAdapter = new HomeHostVideoAdapter(activity, null, R.layout.item_pick_video, 1);
            }
            DividerItemDecoration divider = new DividerItemDecoration(activity, DividerItemDecoration.VERTICAL);
            divider.setDrawable(ContextCompat.getDrawable(activity, R.drawable.shape_list_divider_15dp));
            binding.rlvOptionShare.addItemDecoration(divider);
            binding.rlvOptionShare.setLayoutManager(new GridLayoutManager(activity, 2));
            binding.rlvOptionShare.setAdapter(homeHostVideoAdapter);
            homeHostVideoAdapter.setOnItemClick(new AdapterOnItemClick<VideoBean>() {
                @Override
                public void onItemClick(VideoBean homeHostVideoEntity, int position) {
                    Intent intent = new Intent(activity, PlayListActivity.class);
                    intent.putExtra(PlayListActivity.VIDEOTYPE, "home_zhaocai");
                    intent.putExtra(PlayListActivity.VIDEOLISTBEAN, (Serializable) homeHostVideoAdapter.getDatas());
                    intent.putExtra(PlayListActivity.PSO, position);
                    intent.putExtra(PlayListActivity.PAGE, 1);
                    activity.startActivity(intent);
                }
            });
        }
        updateData();
    }

    @Override
    protected void onLazyLoad() {
        type = (String) getArguments().get(KEY_TYPE);
        initAdapter();
    }

    private void openBidData() {
        if (pickBidingAdapter == null) {
            pickBidingAdapter = new PickHallAllNewAdapter(activity, null);
        }
        LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
        binding.rlvOption.setLayoutManager(layoutManager);
        binding.rlvOption.setAdapter(pickBidingAdapter);

        pickBidingAdapter.setOnItemClick(new AdapterOnItemClick<TenderAllListNewEntity>() {
            @Override
            public void onItemClick(TenderAllListNewEntity tenderAllListNewEntity, int position) {
                viewModel.getH5Url(tenderAllListNewEntity.getId(), "competitivePurchase");
            }
        });
        pickBidingAdapter.onIChildClick(new PickHallAllNewAdapter.IChildClick() {
            @Override
            public void onClick(TenderAllListNewEntity tenderAllListNewEntity) {
                viewModel.getH5Url(tenderAllListNewEntity.getId(), "competitivePurchase");
            }
        });
    }


    public void getAllData(List<TenderAllListEntity> list) {
        if(list == null || list.size() == 0){
            setUpdataView(0);
        } else {
            setUpdataView(list.size());
        }

        if (isLoadMore) {
            if (list != null && list.size() > 0) {
                pickHallAllAdapter.addDatas(list);
            }
        } else {
            if (list != null && list.size() > 0) {
                pickHallAllAdapter.setDatas(list);
            } else {
                pickHallAllAdapter.clearDatas();
            }
        }
    }
    
    public void showBiddingData(List<TenderAllListNewEntity> list) {
        if (list == null || list.size() == 0) {
            setUpdataView(0);
        } else {
            setUpdataView(list.size());
        }
        if (isLoadMore) {
            if (list != null && list.size() > 0) {
                pickBidingAdapter.addDatas(list);
            }
        } else {
            if (list != null && list.size() > 0) {
                pickBidingAdapter.setDatas(list);
            } else {
                pickBidingAdapter.clearDatas();
            }
        }
    }

    public void showCompanyData(List<PickCompanyListEntity> list) {
        if (list == null || list.size() == 0) {
            setUpdataView(0);
        } else {
            setUpdataView(list.size());
        }
        if (isLoadMore) {
            if (list != null && list.size() > 0) {
                pickCompanyListAdapter.addDatas(list);
            }
        } else {
            if (list != null && list.size() > 0) {
                pickCompanyListAdapter.setDatas(list);
            } else {
                pickCompanyListAdapter.clearDatas();
            }
        }
    }

    public void showPickInfoData(List<PickInfoListEntity> list) {
        if (list == null || list.size() == 0) {
            setUpdataView(0);
        } else {
            setUpdataView(list.size());
        }
        if (isLoadMore) {
            if (list != null && list.size() > 0) {
                pickInfoListAdapter.addDatas(list);
            }
        } else {
            if (list != null && list.size() > 0) {
                pickInfoListAdapter.setDatas(list);
            } else {
                pickInfoListAdapter.clearDatas();
            }
        }
    }

    public void showBidingData(List<PreNoticeItemEntity> list) {
        if (list == null || list.size() == 0) {
            setUpdataView(0);
        } else {
            setUpdataView(list.size());
        }
        if (isLoadMore) {
            if (list != null && list.size() > 0) {
                pickWinningNoticeAdapter.addDatas(list);
            }
        } else {
            if (list != null && list.size() > 0) {
                pickWinningNoticeAdapter.setDatas(list);
            } else {
                pickWinningNoticeAdapter.clearDatas();
            }
        }
    }

    public void showHostVideoData(List<VideoBean> list) {
        binding.rlvOptionShare.setLoadingMoreEnabled(false);
        if (list.size() > 0) {
            if (list.size() < 8) {
                binding.tvMore.setVisibility(View.GONE);
                binding.rlvOptionShare.setNoMore(true);
            } else {
                binding.tvMore.setVisibility(View.VISIBLE);
            }
            homeHostVideoAdapter.setDatas(list);
            binding.ntscrollView.setVisibility(View.GONE);
            binding.empty.setVisibility(View.GONE);
            binding.rlvOptionShare.setVisibility(View.VISIBLE);
        } else {
            binding.ntscrollView.setVisibility(View.VISIBLE);
            binding.empty.setVisibility(View.VISIBLE);
            binding.rlvOptionShare.setVisibility(View.GONE);
        }
    }

    private void setUpdataView(int size) {
      /*  if(binding.imgBackTop.getVisibility() == View.GONE){
            if(isLoadMore && size > 0){
                binding.imgBackTop.setVisibility(View.VISIBLE);
            }else{
                binding.imgBackTop.setVisibility(View.GONE);
            }
        }*/

        binding.rlvOption.refreshComplete();
        if (swipeRefreshMainRecruitmentFragment != null) {
            swipeRefreshMainRecruitmentFragment.setRefreshing(false);
        }
        binding.rlvOption.setLoadingMoreEnabled(size != 0);
        if (isLoadMore) {
            binding.rlvOption.loadMoreComplete();
            binding.rlvOption.setVisibility(View.VISIBLE);
        } else {
            binding.rlvOption.refreshComplete();
            binding.rlvOption.setPullRefreshEnabled(false);
            if (size > 0) {
                binding.rlvOption.setVisibility(View.VISIBLE);
                binding.ntscrollView.setVisibility(View.GONE);
                binding.empty.setVisibility(View.GONE);
            } else {
                binding.ntscrollView.setVisibility(View.VISIBLE);
                binding.empty.setVisibility(View.VISIBLE);
                binding.rlvOption.setVisibility(View.GONE);
            }
        }

    }

    /**
     * 监听RecyclerView是否滑动到底部
     *
     * @param recyclerView
     * @return
     */
    private boolean isSlideToBottom(RecyclerView recyclerView) {
        if (recyclerView == null) return false;
        if (recyclerView.computeVerticalScrollExtent() + recyclerView.computeVerticalScrollOffset() >= recyclerView.computeVerticalScrollRange())
            return true;
        return false;
    }

    public void setIsGz(boolean isGz, int position) {
        pickCompanyListAdapter.getDatas().get(position).setFocus(isGz);
        pickCompanyListAdapter.notifyDataSetChanged();
    }

    public void showUrl(String url) {
        WebViewX5HostActivity.start(activity, url);
    }

    public void jumpLogin() {
        boolean shanyan = MkvUtils.get().getBoolean(MkvUtils.CommomData, CacheMarker.ShanYan, false);
        if (shanyan) {
            //校验权限
            //申请动态权限
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                //6.0以上运行时权限处理
                EsayPermissions.with(activity).constantRequest().permission(PERMISSIONS).request(new OnPermission() {
                    @Override
                    public void hasPermission(List<String> granted, boolean isAll) {
                        openLoginPage();
                    }

                    @Override
                    public void noPermission(List<String> denied, boolean quick) {
                        openLoginPage();
                    }
                });

            } else {
                //有权限
                openLoginPage();
            }

        } else {
            VerificationCodeLoginActivity.start(activity, EventConstant.EVENT_MAIN_ACTIVITY_JUMP);
        }
    }

    //闪验
    static final String[] PERMISSIONS = new String[]{
            Manifest.permission.READ_PHONE_STATE
    };

    /**
     * 拉起授权页
     */
    private void openLoginPage() {
        //设置授权页样式
        OneKeyLoginManager.getInstance().setAuthThemeConfig(ConfigUtils.getCJSConfig(activity));
        //开始拉取授权页
        DialogHelper.showProgressDialog(activity, null, "数据加载中", 0, true, null).setCanceledOnTouchOutside(true);
        OneKeyLoginManager.getInstance().openLoginAuth(false, new OpenLoginAuthListener() {
            @Override
            public void getOpenLoginAuthStatus(int code, String result) {
                DialogHelper.dismissProgressDialog();
                if (code != 1000) {
                    VerificationCodeLoginActivity.start(activity, EventConstant.EVENT_MAIN_ACTIVITY_JUMP);
                }
            }
        }, new OneKeyLoginListener() {
            @Override
            public void getOneKeyLoginStatus(int code, String result) {
                DialogHelper.dismissProgressDialog();
                if (code == 1000) {
                    OneKeyLoginEntity oneKeyLoginEntity = GsonManager.getInstance().getGson().fromJson(result, OneKeyLoginEntity.class);
                    oneKeyLoginEntity.setPlateform("Android");
                    viewModel.oneKeyLogin(oneKeyLoginEntity);
                }
            }
        });
    }

    /**
     * 一键登录成功
     *
     * @param loginEntity
     * @param phoneNumber
     */
    public void loginSucceed(LoginEntity loginEntity, String phoneNumber) {
        LoginEvent loginEvent = new LoginEvent();
        loginEvent.setMessageData(phoneNumber);
        loginEvent.setMessageTag(EventConstant.EVENT_LOGIN);
        loginEvent.setObject(loginEntity);
        EventBus.getDefault().postSticky(loginEvent);
    }

    public void getUserMsgSucceed(UserMsgEntity userMsgEntity) {
        LoginEvent loginEvent = new LoginEvent();
        loginEvent.setMessageTag(EventConstant.EVENT_USER_MSG);
        loginEvent.setMessageData(userMsgEntity);
        EventBus.getDefault().postSticky(loginEvent);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(MachinePublishEvent event) {
       /* if (event.getMessageTag() == R.layout.item_home_pick_type) {
            viewModel.getMaterialListModel(type);
        } else if (event.getMessageTag() == R.layout.item_home_pick_device) {
            viewModel.getMaterialListModel(type);
        } else if (event.getMessageTag() == R.layout.item_pick_packers) {
            viewModel.getMaterialListModel(type);
        } else if (event.getMessageTag() == R.layout.item_home_pick_labour) {
            viewModel.getMaterialListModel(type);
        }*/
    }

    public void getUrl(String url, String id) {
        WebViewX5HostActivity.start(getActivity(), url, id);
    }

    public void setTypeNo(String typeNoOne, String typeNo, String goodsType, String mType) {
        if (!isAdded()){
            return;
        }
        isLoadMore = false;
        page = 1;
        if (TextUtils.isEmpty(mType)) {
            DialogHelper.dismissProgressDialog();
            return;
        }
        typeNoOnePosition = typeNoOne;
        typeNoPosition = typeNo;
        goodsTypeNoPosition = goodsType;
        type = mType;
        updateData();
    }

}
